#include <glib.h>

void _list_interger_print_func(gpointer data, gpointer user_data)
{
    g_print("data is: %d, user_data is: %s \n", GPOINTER_TO_INT(data), (gchar *)user_data);
}

gint main(gint argc, gchar **argv)
{
    GList *list1 = NULL;
    GList *list2 = NULL;
    GList *l = NULL;

    list1 = g_list_append(list1, GINT_TO_POINTER(1));
    list1 = g_list_append(list1, GINT_TO_POINTER(5));
    list2 = g_list_append(list2, GINT_TO_POINTER(3));
    list2 = g_list_append(list2, GINT_TO_POINTER(7));


    g_list_foreach(list1, _list_interger_print_func, (gchar *)"list1");
    g_list_foreach(list2, _list_interger_print_func, (gchar *)"list2");

    g_print("===test concat=== \n");

    list1 = g_list_concat(list1, list2);
    g_list_foreach(list1, _list_interger_print_func, (gchar *)"list1-concat");
    g_list_foreach(list2, _list_interger_print_func, (gchar *)"list2-concat");

    g_print("===test move last to front=== \n");
    l = g_list_last(list1);
    list1 = g_list_remove_link(list1, l);
    list1 = g_list_concat(l, list1);

    g_list_foreach(list1, _list_interger_print_func, (gchar *)"list1-move-to-front");
    g_list_foreach(list2, _list_interger_print_func, (gchar *)"list2-move-to-front");

    g_list_free(list1);

    return 0;
}